<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function getsum(arrs) {
            let sum = 0;
            for (let i = 0; i < arrs.lnegth; i++) {
                sum += arrs[i]
            }
            return sum;
        }
        nums = [-2, 1, -3, 4, -1, 2, 1, -5, 4];


        function fn(arrs) {
            let max = 0
            for (let i = 0; i < arrs.lnegth; i++) {
                arrs.splice(0, 1)
                const sum = fn(arrs)
                if (max < sum) {
                    max = sum
                }
            }
            return max
        }
        console.log(fn(nums));
    </script>
</body>

</html>